/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sorts;

/**
 *
 * @author Matias
 */
public class bubbleSort extends sort{
    
    public static void sort(int data[], int n)
// pre: 0 <= n <= data.length
// post: values in data[0..n-1] in ascending order
    {
        int numSorted = 0; // number of values in order
        int index; // general index
        while (numSorted < n)
        {
            // bubble a large element to higher array index
            for (index = 1; index < n-numSorted; index++)
            {
                if (data[index-1] > data[index])
                    swap(data,index-1,index);
            }
            // at least one more value in place
            numSorted++;
        }
        
        for(int i=0 ; i< n ; i++)
            System.out.println(data[i]);
    }

    
    
    
}
